package com.ruoyi.system.service.construction.impl;

import com.ruoyi.common.constant.UserConstants;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.system.domain.construction.Team;
import com.ruoyi.system.domain.zhuangxiumain.shopMain.SupplierInfo;
import com.ruoyi.system.mapper.construction.TeamMapper;
import com.ruoyi.system.mapper.zhuangxiumapper.shopMapper.SupplierInfoMapper;
import com.ruoyi.system.service.construction.TeamService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

@Service
public class TeamServiceImpl implements TeamService
{

    @Autowired
    private TeamMapper teamMapper;


    /**
     * 查询所有分类信息
     * @param team
     * @return
     */
    @Override
    public List<Team> selectTeamList(Team team) {
        return teamMapper.selectTeamList(team);
    }

    /**
     * 根据分类ID查询
     * @param teamId
     * @return
     */
    @Override
    public Team selectTeamById(Long teamId){
        return teamMapper.selectTeamById(teamId);
    }

    /**
     * 根据分类名称查询
     * @param teamName
     * @return
     */
    @Override
    public Team selectTeamByName(String teamName){
        return teamMapper.selectTeamByName(teamName);
    }

    /**
     * 根据人员ID查询类别Id
     * @param constructionId
     * @return
     */
    @Override
    public int selectTeamByInfoId(Long constructionId){
        return teamMapper.selectTeamByInfoId(constructionId);
    }

    /**
     * 校验类别名称
     * @param team
     * @return
     */
    @Override
    public String checkTeamNameUnique(Team team){
        Team team1 = teamMapper.checkTeamNameUnique(team);
        if (team1 != null && !team1.getDelFlag().equals("2"))
        {
            return UserConstants.NOT_UNIQUE;
        } else if (team1!=null && team1.getDelFlag().equals("2")){
             teamMapper.updateDelFlag(team);
        }
        return UserConstants.UNIQUE;
    }

    /**
     * 添加分类信息
     * @param team
     * @return
     */
    @Override
    public int insertTeam(Team team){
        team.setStatusType("0");
        return teamMapper.insertTeam(team);
    }

    /**
     * 删除分类信息
     * @param teamId
     * @return
     */
    @Override
    public int deleteTeam(Long teamId){
        return teamMapper.deleteTeam(teamId);
    }

    /**
     * 批量删除分类信息
     * @param ids
     * @return
     */
    @Override
    public int deleteTeamByIds(Long[] ids){
        return teamMapper.deleteTeamByIds(ids);
    }

    /**
     * 修改分类信息
     * @param team
     * @return
     */
    @Override
    public int updateTeam(Team team){
        return teamMapper.updateTeam(team);
    }
    /**
     * 修改分类状态
     * @param team
     * @return
     */
    @Override
    public int updateTeamStatus(Team team){
        return teamMapper.updateTeamStatus(team);
    }

    @Override
    public List<Team> findAll() {
        return teamMapper.findAll();
    }




    @Override
    public Team apifindAllListTeamById(Long teamId) {
        return teamMapper.apifindAllListTeamById(teamId);
    }

    @Override
    public List<Team> apifindAllListTeamOne(Team team) {
        return teamMapper.apifindAllListTeamOne(team);
    }

    @Override
    public List<Team> apifindAllListTeamTwo(Team team) {
        return teamMapper.apifindAllListTeamTwo(team);
    }

    @Override
    public int apiInsertTeam(Team team) {
        return teamMapper.apiInsertTeam(team);
    }

    @Override
    public int apiInsertTeamTwo(Team team) {
        return teamMapper.apiInsertTeamTwo(team);
    }

    @Override
    public int apiUpdateTeam(Team team) {
        return teamMapper.apiUpdateTeam(team);
    }

    @Override
    public int apiUpdateTeamTwo(Team team) {
        return teamMapper.apiUpdateTeamTwo(team);
    }

    @Override
    public int apiDeleteTeamByIds(Long[] teamId) {
        return teamMapper.apiDeleteTeamByIds(teamId);
    }

    @Override
    public int apiDeleteTeamByIdsTwo(Long[] teamId) {
        return teamMapper.apiDeleteTeamByIdsTwo(teamId);
    }

    //TODO: 普通用户查询超管的施工队类别列表
    public List<Team> selectStatusTeamList(String teamType){
        return teamMapper.selectStatusTeamList(teamType);
    }

    //TODO: 超管：根据店铺ID查询分类列表
    public List<Team> selectSuperTeamList(Team team){
        return teamMapper.selectSuperTeamList(team);
    }
}
